package com.qfedu.inspectionReception.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.common.R;
import com.qfedu.inspectionReception.dto.InspectionReceptionDTO;
import com.qfedu.inspectionReception.dto.InspectionReceptionStateDto;
import com.qfedu.inspectionReception.pojo.InspectionReception;
import com.qfedu.inspectionReception.service.InspectionReceptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.UUID;


@RestController
@RequestMapping("/inspectionReception")
public class InspectionReceptionController {

    @Resource
    private InspectionReceptionService inspectionReceptionService;


    @GetMapping
    public R<Page<InspectionReception>> getInspectionReceptions(InspectionReceptionDTO inspectionReceptionDTO) {
        return R.ok(inspectionReceptionService.getInspectionReceptions(inspectionReceptionDTO));
    }

    @PostMapping
    public R<Boolean> addInspectionReception(@RequestBody InspectionReception inspectionReception) {

        return R.ok(inspectionReceptionService.saveInspectionReception(inspectionReception));
    }

    @PutMapping
    public R<Boolean> updateInspectionReception(@RequestBody InspectionReception inspectionReception) {
        return R.ok(inspectionReceptionService.updateById(inspectionReception));
    }

    @DeleteMapping("/{id}")
    public R<Boolean> deleteInspectionReception(@PathVariable("id") String id) {
        return R.ok(inspectionReceptionService.removeById(id));
    }

    @PutMapping("/state")
    public R<Boolean> changeUseState(@RequestBody InspectionReceptionStateDto inspectionReceptionStateDto) {
        return R.ok(inspectionReceptionService.changeUseState(inspectionReceptionStateDto));
    }
}
